package Testpackage;

import java.io.*;
import java.net.*;


public class ServerThread extends Thread {
	private Socket verbindung = null;
	
	
	public ServerThread (Socket verbindung){
		this.verbindung = verbindung;
		System.out.println("ServerThread instanziert");
		Thread t = new Thread(this);
		t.start();
	}
	
	public void run(){
		try{
			BufferedReader in = new BufferedReader(new InputStreamReader(
					verbindung.getInputStream()));
			OutputStreamWriter out = new OutputStreamWriter(
					verbindung.getOutputStream());
			
			StringBuffer request = new StringBuffer();
			String lineIn = in.readLine();
			while(lineIn != null){
				request.append(lineIn);
				request.append("\n");
				lineIn = in.readLine();
			}
			
			System.out.println("Server: "+request.toString());
			
			out.write(request.toString());
			out.flush();
			
			in.close();
			out.close();
			
		}catch (IOException e){
			System.out.println(e.toString());
			
		}
	}

}